#!/usr/bin/env python

"""This script takes an argument that should be a 
configuration file for Serial Box. It uses the 
OpenFile and CheckConfig files.

Author: Justin Christian
Date: April 1, 2008
Language: Python
"""

import os

def parser (configLocation):
    """Parse a configuration file to be usable
    by Serial Box.

    Returns a dictionary defining the necessary variables"""
    
	

    #open the file
    try:
        configFile = open (configLocation)
    except IOError:
        print "File %s Not Found" % configLocation
        exit()
   	


	#do parsing stuff
	for line in configFile:
		if line[0] != '#' and line[0] != '\n':
			list = line.split()
			if list[0] == 'Type_Of_Module':
				ModType = list[-1]
			elif list[0] == 'Excerpt_Location':
				ExLoc = list[-1]
			elif list[0] == 'Forte_Answer':
				FrtAns = list[-1]
			elif list[0] == 'IntervalVector_Answer':
				IntVecAns = list[-1]
		else: #we must be at EOF
			break
			
	print ModType, ExLoc, FrtAns, IntVecAns

if __name__ == "__main__":
    # initialize a new string for the location 
    configLocation = []
    configLocation = raw_input("Config File Location: ")
    
    parser(configLocation)
